// Decompiled by DJ v3.9.9.91 Copyright 2005 Atanas Neshkov  Date: 2008-7-13 22:05:06
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   ImageViewServlet.java

import java.io.*;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;

public class ImageViewServlet extends HttpServlet
{

    public ImageViewServlet()
    {
    }

    public void init()
        throws ServletException
    {
    }

    public void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws IOException
    {
	    	resp.setHeader("Pragma","No-cache"); 
	    	resp.setHeader("Cache-Control","no-cache"); 
	    	resp.setDateHeader("Expires", -10);
	    	
        ServletContext sc = getServletContext();
        String filename = req.getParameter("file");
        String mimeType = sc.getMimeType(filename);
        if(mimeType == null)
        {
            sc.log((new StringBuilder("Could not get MIME type of ")).append(filename).toString());
            resp.setStatus(500);
            return;
        }
        resp.setContentType(mimeType);
        File file = new File(filename);
        resp.setContentLength((int)file.length());
        FileInputStream in = new FileInputStream(file);
        OutputStream out = resp.getOutputStream();
        byte buf[] = new byte[1024];
        for(int count = 0; (count = in.read(buf)) >= 0;)
            out.write(buf, 0, count);

        in.close();
        out.close();
    }

    public void destroy()
    {
    }

    public static void main(String args1[])
    {
    }
}